//
//  WCTabView.m
//  WabbitCode
//
//  Created by William Towe on 2/3/09.
//  Copyright 2009 Revolution Software. All rights reserved.
//

#import "WCTabView.h"


@implementation WCTabView
- (void)drawRect:(NSRect)rect {
	[super drawRect:rect];
	
	static NSGradient *gradient = nil;
	static NSAttributedString *string = nil;
	if (!gradient) {
		gradient = [[NSGradient alloc] initWithStartingColor:[NSColor lightGrayColor] endingColor:[NSColor darkGrayColor]];
		//gradient = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithCalibratedWhite:0.12 alpha:1.0] endingColor:[NSColor colorWithCalibratedWhite:0.38 alpha:1.0]];
		//gradient = [[NSGradient alloc] initWithStartingColor:[NSColor whiteColor] endingColor:[NSColor lightGrayColor]];
		
		NSMutableParagraphStyle *style = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
		[style setAlignment:NSCenterTextAlignment];
		NSShadow *shadow = [[[NSShadow alloc] init] autorelease];
		[shadow setShadowOffset:NSMakeSize(2.0, -2.0)];
		[shadow setShadowBlurRadius:1.0];
		
		string = [[NSAttributedString alloc] initWithString:NSLocalizedString(@"No Open Files",@"No Open Files") attributes:[NSDictionary dictionaryWithObjectsAndKeys:[NSFont systemFontOfSize:30.0], NSFontAttributeName, style, NSParagraphStyleAttributeName, [NSColor whiteColor], NSForegroundColorAttributeName, shadow, NSShadowAttributeName, nil]];
	}
	
	NSRect bounds = [self bounds];
	
	[gradient drawInRect:bounds angle:90.0];
	NSRect title = [string boundingRectWithSize:bounds.size options:NSStringDrawingOneShot];
	NSRect draw = rect;
	draw.size.height = title.size.height;
	draw.origin.y = bounds.origin.y+floorf(bounds.size.height/2)-floorf(title.size.height/2);
	
	[string drawInRect:draw];
}
@end
